/*
 * @Copyright: 2017 www.yyfax.com Inc. All rights reserved.
 */
package com.yyfax.pay.order.model.to.route;

import org.hibernate.validator.constraints.NotBlank;

import com.yyfax.framework.model.Params;
import com.yyfax.framework.yyfax.enums.RspCodeEnum;
import com.yyfax.pay.common.enums.PayTypeEnum;
import com.yyfax.pay.common.exception.YYPayException;

/**
 * 路由信息请求实体
 * 
 * @author buyi
 * @date 2017-04-27 17:11:56
 * @since v1.0.0
 */
@SuppressWarnings("serial")
public class RouteApiDirectParams extends Params {
	@NotBlank(message = "银行卡号不能为空")
	private String cardNo;
	/** 支付类型，{@link PayTypeEnum} */
	@NotBlank(message = "支付类型不能为空")
	private String payType;

	public String getCardNo() {
		return cardNo;
	}

	public void setCardNo(String cardNo) {
		this.cardNo = cardNo;
	}

	public String getPayType() {
		return payType;
	}

	public void setPayType(String payType) {
		this.payType = payType;
	}

	@Override
	public boolean validate() throws Exception {
		// 如果不是支付，或者独立鉴权，则抛出异常
		if (!PayTypeEnum.PAY.isValue(payType) && !PayTypeEnum.AUTH.isValue(payType)) {
			throw new YYPayException(RspCodeEnum.COMMON_ERROR_PARAMETER_INVALID, "payType不是合法的类型", "payType不是合法的类型");
		}

		return true;
	}

}
